package com.neuedu.hostp.dao;

import com.neuedu.hostp.entity.Checkin;
import org.apache.ibatis.jdbc.SQL;

public class CheckinSqlProvider {

    public String insertSelective(Checkin record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("check_in");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getCustomerId() != null) {
            sql.VALUES("customer_id", "#{customerId,jdbcType=INTEGER}");
        }
        
        if (record.getCheckInTime() != null) {
            sql.VALUES("check_in_time", "#{checkInTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCheckOutTime() != null) {
            sql.VALUES("check_out_time", "#{checkOutTime,jdbcType=VARCHAR}");
        }
        
        if (record.getBedId() != null) {
            sql.VALUES("bed_id", "#{bedId,jdbcType=INTEGER}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Checkin record) {
        SQL sql = new SQL();
        sql.UPDATE("check_in");
        
        if (record.getCustomerId() != null) {
            sql.SET("customer_id = #{customerId,jdbcType=INTEGER}");
        }
        
        if (record.getCheckInTime() != null) {
            sql.SET("check_in_time = #{checkInTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCheckOutTime() != null) {
            sql.SET("check_out_time = #{checkOutTime,jdbcType=VARCHAR}");
        }
        
        if (record.getBedId() != null) {
            sql.SET("bed_id = #{bedId,jdbcType=INTEGER}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}